package com.vincent;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

import javax.jms.*;

/**
 * Created by vincent on 2018/7/29.
 */
public class ProduceTest {
    public static void main(String[] args) throws JMSException {
        String url = "tcp://192.168.1.2:61616";
        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = session.createQueue("test-queue");
        //Destination destination = new ActiveMQQueue("");
        MessageProducer producer = session.createProducer(destination);
        for (int i = 0; i < 100; i++) {
            TextMessage xixi = session.createTextMessage("hehe-"+i);
            producer.send(xixi);
        }
        producer.close();
        session.close();
        connection.close();
    }
}
